/**
 *入职指引 第三步
 */
import React from 'react';
import { createForm } from 'rc-form';
import { Icon } from 'antd';
import { useRequest, defaultFormatResult } from '@/hooks';
import { getEntryNotes } from '@/pages/EntryManage/services';
import xss from 'xss';

// 信息确认
const StepNotice = ({ entryPersonnelData }) => {
    const {
        entryPersonnelCode,
        isChinaArea = true,
        organizationLocationVO,
        contractOrganizationName
    } = entryPersonnelData;

    const { latitude, longitude } = organizationLocationVO || {};

    // 获取入职需知内容
    const { data } = useRequest(() => getEntryNotes({ entryPersonnelCode }), {
        ...defaultFormatResult
    });

    const openMap = () => {
        if (isChinaArea === true) {
            // 跳转高德地图
            window.location.href = `https://uri.amap.com/marker?position=${longitude},${latitude}&name=${contractOrganizationName}&src=mypage&coordinate=gaode&callnative=1`;
        } else {
            // 跳转谷歌地图
            window.location.href = `https://www.google.com/maps/search/?api=1&query=${latitude},${longitude}&query_place_id=${contractOrganizationName}`;
        }
    };

    return (
        <>
            <div className="formContainer2">
                <div className="noticeContent2" dangerouslySetInnerHTML={{ __html: xss(data) }} />

                {/* 临时隐藏，等产品需求开启 */}
                <div style={{ display: 'none' }}>
                    <a onClick={openMap}>
                        <Icon type="environment" />
                    </a>
                </div>
            </div>
        </>
    );
};

export default createForm()(StepNotice);
